:root {
    /* Light theme variables */
    --bg-primary: #F9F9F9;
    --bg-secondary: white;
    --text-primary: #24292e;
    --text-secondary: #111;
    --border-color: #ddd;
    --link-color: #0366d6;
    --code-bg: #f6f8fa;
    --pre-bg: #f6f8fa;
    --nav-hover: #0366d6;
    --github-corner-fill: #202020;
    --github-corner-color: #fff;
    
    /* Dark theme color definitions */
    --dark-bg-primary: #0d1117;
    --dark-bg-secondary: #161b22;
    --dark-text-primary: #e6edf3;
    --dark-text-secondary: #f0f6fc;
    --dark-border-color: #30363d;
    --dark-link-color: #58a6ff;
    --dark-code-bg: #262c36;
    --dark-pre-bg: #262c36;
    --dark-nav-hover: #58a6ff;
    --dark-github-corner-fill: #f0f6fc;
    --dark-github-corner-color: #0d1117;
}

[data-theme="dark"] {
    /* Dark theme variables */
    --bg-primary: var(--dark-bg-primary);
    --bg-secondary: var(--dark-bg-secondary);
    --text-primary: var(--dark-text-primary);
    --text-secondary: var(--dark-text-secondary);
    --border-color: var(--dark-border-color);
    --link-color: var(--dark-link-color);
    --code-bg: var(--dark-code-bg);
    --pre-bg: var(--dark-pre-bg);
    --nav-hover: var(--dark-nav-hover);
    --github-corner-fill: var(--dark-github-corner-fill);
    --github-corner-color: var(--dark-github-corner-color);
}

/* Respect system preference when no explicit theme is set */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg-primary: var(--dark-bg-primary);
        --bg-secondary: var(--dark-bg-secondary);
        --text-primary: var(--dark-text-primary);
        --text-secondary: var(--dark-text-secondary);
        --border-color: var(--dark-border-color);
        --link-color: var(--dark-link-color);
        --code-bg: var(--dark-code-bg);
        --pre-bg: var(--dark-pre-bg);
        --nav-hover: var(--dark-nav-hover);
        --github-corner-fill: var(--dark-github-corner-fill);
        --github-corner-color: var(--dark-github-corner-color);
    }
}

body {
    font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";
    font-size: 16px;
    line-height: 1.5;
    word-wrap: break-word;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

#container {
    max-width: 900px;
    margin: auto;
}

#content {
    padding: 5px 10px;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    background: var(--bg-secondary);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

#content h1:first-child {
    margin-top: 0px;
}

nav {
    border: 1px solid var(--border-color);
    border-radius: 3px;
    background: var(--bg-secondary);
    margin-right: 10px;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

nav > ul {
    position: sticky;
    top: 5px;
    margin: 10px 0px;
    padding: 0;
    list-style-type: none;
    font-size: 14px;
}

nav > ul > li {
    min-width: 125px;
    padding: 0px 15px;
}

nav > ul > li > ul {
    padding-left: 25px;
}

nav > ul > li > ul > li {
    font-size: 0.8em;
}

nav .selected {
    color: var(--text-secondary);
    font-weight: bold;
}

nav .selected:hover {
    text-decoration: none;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-inline-end: 70px;
}

header h1 { margin: 0; }

.header-content {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Dark mode toggle */
.theme-toggle {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.theme-toggle:hover {
    background-color: var(--code-bg);
}

.theme-toggle:focus {
    outline: 2px solid var(--link-color);
    outline-offset: 2px;
}

.theme-toggle .icon {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

table {
    border-spacing: 0;
    border-collapse: collapse;
    border: 1px solid var(--border-color);
}

td, th {
    border: 1px solid var(--border-color);
    padding: 5px;
}

a {
    color: var(--link-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    text-decoration: underline;
}

pre {
    font-family: "SFMono-Regular",Consolas,"Liberation Mono",Menlo,Courier,monospace;
    padding: 16px;
    overflow: auto;
    font-size: 85%;
    line-height: 1.45;
    background-color: var(--pre-bg);
    border-radius: 3px;
    position: relative;
    max-width: 680px;
    transition: background-color 0.3s ease;
}

pre code {
    max-width: 680px;
    overflow: auto;
    display: block;
}

:not(pre) > code {
    padding: 0.2em 0.4em;
    margin: 0;
    font-size: 85%;
    background-color: var(--code-bg);
    border-radius: 3px;
    transition: background-color 0.3s ease;
}

summary {
    cursor: pointer;
    padding: 3px 0px;
}

summary:hover {
    color: var(--nav-hover);
}

.div-copy {
    position: absolute;
    top: 0;
    right: 0;
}

.div-copy .icon-copy {
    opacity: 0;
    transition: opacity .3s;
    height: 18px;
    width: 18px;
    cursor: pointer;
    padding: 5px;
}

.div-copy.active .icon-copy {
    opacity: 1;
}

.div-copy .tooltip-copy {
    position: relative;
}

.div-copy .tooltip-copy::before {
    content: "Copied";
    position: absolute;

    /* vertically center */
    top: 50%;
    transform: translateY(-50%);

    /* move to right */
    right: 100%;
    margin-right: 5px; /* and add a small left margin */

    /* basic styles */
    padding: 2px 7px;
    border-radius: 5px;
    background: #444;
    color: #fff;
    text-align: center;

    opacity: 0; /* hide by default */
    transition: opacity .3s;
}

.div-copy.click .tooltip-copy::before {
    opacity: 1;
}

.div-copy .tooltip-copy::after {
    content: "";
    position: absolute;

    /* position tooltip correctly */
    right: 100%;
    margin-right: -5px;

    /* vertically center */
    top: 50%;
    transform: translateY(-50%);

    /* the arrow */
    border-style: solid;
    border-width: 2px 2px 5px 8px;
    border-color: transparent transparent transparent #444;

    opacity: 0;
    transition: opacity .3s;
}

.div-copy.click .tooltip-copy::after {
    opacity: 1;
}
